package com.daipresents.logging.logback;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.util.StatusPrinter;

public class LogBackJoranSample {
    final static Logger logger = LoggerFactory.getLogger(LogBackJoranSample.class);

    public static void main(String[] args) {
      // assume logback is in use
      LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
      
      try {
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(lc);
        // the context was probably already configured by default configuration 
        // rules
        lc.shutdownAndReset(); 
        configurator.doConfigure("D:/Study/workspace/LoggerTest/src/main/resources/logback.xml");
      } catch (JoranException je) {
         je.printStackTrace();
      }
      StatusPrinter.printIfErrorsOccured(lc);

      logger.info("Entering application.");

      logger.debug("fujihara.");
      
      logger.info("Exiting application.");
    }

}
